package com.woniuxy.mqconsumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EsConfig {
    public static final String ES_EXCHANGE = "es_exchange";
    public static final String ES_ROUTING_KEY = "es_routing_key";
    public static final String ES_QUEUE = "es_queue";

    @Bean
    public DirectExchange esDirectExchange(){
        return new DirectExchange(ES_EXCHANGE,true,false);
    }
    @Bean
    public Queue esQueue(){
        return QueueBuilder.durable(ES_QUEUE).build();
    }
    @Bean
    public Binding bindEsDirectExchangeAndEsQueue(){
        return BindingBuilder.bind(esQueue()).to(esDirectExchange()).with(ES_ROUTING_KEY);
    }
}
